var app = getApp();
var utils = require("./utils.js");

/**
 * 推薦貨品
 * query 货品编号 （可不传）
 */
function itemRegoods(query, cb) {
  var url = app.globalData.baseUrl + "/aitem/regoods";
  var data = reqParam(query);
  utils.http(url, data, "post", cb)
}

/**
 * 同類價格
 * query 货品编号  
 */
function itemSimilar(query, cb) {
  var url = app.globalData.baseUrl + "/aitem/similarprice";
  var data = reqParam(query);
  utils.http(url, data, "post", cb)
}

/**
 * 查询货品详情
 */
function itemDetails(query, cb) {
  var url = app.globalData.baseUrl + "/aitem/item";
  var data = reqParam(query);
  utils.http(url, data, "post", cb)
}

/**
 * 查询数据
 */
function filterScreen(query, cb) {
  var url = app.globalData.baseUrl + "/aitem/screening";
  var data = reqParam(query);
  utils.http(url, data, "post", cb)
}

/**
 * 查询数据
 */
function searchItem(query,cb) {
  var url = app.globalData.baseUrl + "/aitem/search";
  var data = reqParam(query);
  utils.http(url, data, "post", cb)
}

/**
 * 分类
 */
function acategory(cb) {
  var url = app.globalData.baseUrl + "/ahome/mcatalog";
  var data = reqParam(null);
  utils.http(url, data, "post", cb)
}

function scategory(cb) {
  var url = app.globalData.baseUrl + "/ahome/scatalogs";
  var data = reqParam(null);
  utils.http(url, data, "post", cb)
}
 
/**
 * 主页请求
 */

function ahome(cb)
{
  var url = app.globalData.baseUrl + "/ahome/allimg";
  var data = reqParam(null);
  utils.http(url,data,"post",cb)
}

function reqParam(vipcontent)
{
  return {
    "commonInfo": app.globalData.commonInfo,
    "tokenInfo": app.globalData.tokenInfo,
    "vipcontent": vipcontent
  };
}

module.exports = {
  ahome: ahome,
  acategory: acategory,
  scategory: scategory,
  searchItem: searchItem,
  filterScreen: filterScreen,
  itemDetails:itemDetails,
  itemSimilar: itemSimilar,
  itemRegoods: itemRegoods
}
